package day21.TaskWithBraces;

import java.util.Stack;

public class Brackets {

	static boolean isExpressionBalanced(String expression) {
		Stack stack = new Stack();

		for (int index = 0; index < expression.length(); index++) {
			char c = expression.charAt(index);

			if (c == '(') {
				stack.push("baba");
			} else if (c == ')') {
				if (stack.isEmpty()) {
					return false;
				} else {
					stack.pop();
				}
			}
		}

		if (!stack.isEmpty()) {
			return false;
		}
		return true;
	}

	public static void main(String[] args) {
		System.out.println(isExpressionBalanced("))"));

	}

}
